<template>
  <div class="address">
    <div class="address_nav">
      <van-nav-bar title="地址" left-text="返回" left-arrow @click-left="onClickLeft" />
    </div>
    <div class="address_button">
      <van-button type="primary" block color="#FF976A" to="/manager/addAddress" size="large">新增地址</van-button>
    </div>
    <div class="address_text">
      <div class="item" v-for="c in addressId" :key="c.id" :value="c.id" :label="c.id">
        <div class="item_left">
          <div class="item_one">
            <span>{{customerById.username}}</span>
            <span>{{c.telephone}}</span>
          </div>
          <div class="item_two">
            <span>{{c.province}}{{c.city}}{{c.area}}</span>
            <span>{{c.address}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { mapActions, mapState } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState("money", ["customerById"]),
    ...mapState("address", ["addressId"])
  },
  created() {
    this.toFindCustomer();
  },
  methods: {
    ...mapActions("money", ["findCustomer"]),
    ...mapActions("address", ["loadAddressId", "toDeleteId"]),
    onClickLeft() {
      this.$router.push({ path: "/manager/user" });
    },
    toFindCustomer() {
      let id = localStorage.getItem("id");
      this.findCustomer(id);
      this.loadAddressId(id);
    }
  }
};
</script>
<style scope>
.item {
  width: 92%;
  height: 60px;
  background-color: #fff;
  position: relative;
  border-radius: 10px;
  margin: 5px 10px 0 10px;
}
.item_left {
  width: 100%;
  float: left;
}

.address {
  background-color: #eee;
}
.address_text {
  height: calc(100vh - 10px);
}
.item_one {
  width: 50px;
  line-height: 32px;
  margin-left: 20px;
}
.item_two {
  margin-left: 20px;
}
.item_one > span,
.item_two > span {
  margin-right: 10px;
}
</style>